<?php

use App\Admin\Grid\Displayers\EditableWithAuth;
use App\Admin\Grid\Displayers\SelectWithAuth;
use Dcat\Admin\Admin;
use Dcat\Admin\Grid;
use Dcat\Admin\Form;
use Dcat\Admin\Grid\Filter;
use Dcat\Admin\Show;
use Dcat\Admin\Grid\Column;

/**
 * Dcat-admin - admin builder based on Laravel.
 * @author jqh <https://github.com/jqhph>
 *
 * Bootstraper for Admin.
 *
 * Here you can remove builtin form field:
 *
 * extend custom field:
 * Dcat\Admin\Form::extend('php', PHPEditor::class);
 * Dcat\Admin\Grid\Column::extend('php', PHPEditor::class);
 * Dcat\Admin\Grid\Filter::extend('php', PHPEditor::class);
 *
 * Or require js and css assets:
 * Admin::css('/packages/prettydocs/css/styles.css');
 * Admin::js('/packages/prettydocs/js/main.js');
 *
 */
Admin::pjax();
Admin::css(asset('//at.alicdn.com/t/c/font_4394599_ea54fenu77a.css'));
Admin::css(asset('css/admin/admin.css?v=2'));
Admin::js(asset('js/admin/admin.js?v=2'));
app('view')->prependNamespace('admin', resource_path('views/admin'));

config(['admin.layout.horizontal_menu' => true]);
// if (isMobile()) {
//     config(['admin.layout.horizontal_menu' => false]);
// }

Column::extend('editable_auth', EditableWithAuth::class);
Column::extend('select_auth', SelectWithAuth::class);

Grid::resolving(function(Grid $grid) {
    $grid->toolsWithOutline(false);
    $grid->disableRefreshButton();
    $grid->disableBatchDelete();
    $grid->disableBatchActions();
    $grid->disableFilterButton();
    $grid->disableRowSelector();
    $grid->withBorder(true);
});

Form::resolving(function (Form $form) {
    $form->disableEditingCheck();

    $form->disableCreatingCheck();

    $form->disableViewCheck();
    

    $form->tools(function (Form\Tools $tools) {
         $tools->disableDelete();
         $tools->disableView();
    });

});

Show::resolving(function(Show $show) {
    $show->disableDeleteButton();
    $show->disableEditButton();
});

Filter::resolving(function(Filter $filter) {
    $filter->panel()->expand();
});
